package android.ijiajiao.dao.impl;

import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.util.ArrayList;

import android.ijiajiao.dao.ContractDao;
import android.ijiajiao.util.JDBCConnectUtil;

public class ContractDaoImpl implements ContractDao {

	@Override
	public ArrayList<Object> contractList(String name) {
		Connection conn = JDBCConnectUtil.getConnection();
		PreparedStatement ps = null;
		ResultSet rs = null;
		String sql = "select contract_id,apply_contract_name,contract_state,contract_time,info_id,course,coach_time,apply_time,apply_phone from contract where contract_name=?";
		ArrayList<Object> data = new ArrayList<>();
		try {
			ps = conn.prepareStatement(sql);
			ps.setString(1, name);
			rs = ps.executeQuery();
			while (rs.next()) {
				ArrayList<Object> listdata = new ArrayList<>();
                listdata.add(rs.getString(1));         
                listdata.add(rs.getString(2));         
                listdata.add(rs.getString(3));         
                listdata.add(rs.getString(4));         
                listdata.add(rs.getString(5));         
                listdata.add(rs.getString(6));         
                listdata.add(rs.getString(7));         
                listdata.add(rs.getString(8));         
                listdata.add(rs.getString(9));         
                data.add(listdata);
			}

		} catch (Exception e) {
			// TODO: handle exception
		} finally {
			JDBCConnectUtil.close(rs, null, ps, conn);
		}
		return data;
	}

	@Override
	public boolean docontract(int contract_id) {
		// TODO Auto-generated method stub
		
		return false;
	}

}
